<?php 
class DomBaseTestCase extends UnitTestCase {
	
	public function testGet_called_class() {
	
		$this->assertEqual( get_called_classTestClass::test1(), 'get_called_classTestClass');
		$this->assertEqual( get_called_classTestClass::test2(), 'get_called_classTestClass');
		$this->assertEqual( get_called_classExtTestClass::test1(), 'get_called_classExtTestClass');
		$this->assertEqual( get_called_classExtTestClass::test2(), 'get_called_classExtTestClass');
		
		$this->assertEqual( call_user_func(array('get_called_classTestClass','test1')), 'get_called_classTestClass');
		$this->assertEqual( call_user_func(array('get_called_classTestClass','test2')), 'get_called_classTestClass');
		$this->assertEqual( call_user_func(array('get_called_classExtTestClass','test1')), 'get_called_classExtTestClass');
		$this->assertEqual( call_user_func(array('get_called_classExtTestClass','test2')), 'get_called_classExtTestClass');
		
		//$this->assertEqual( eval('return get_called_classTestClass::test1();'), 'get_called_classTestClass');
		//$this->assertEqual( eval('return get_called_classTestClass::test2();'), 'get_called_classTestClass');
		//$this->assertEqual( eval('return get_called_classExtTestClass::test1();'), 'get_called_classExtTestClass');
		//$this->assertEqual( eval('return get_called_classExtTestClass::test2();'), 'get_called_classExtTestClass');
	}

	
	public function test_sortToTree() {
		
		// TEST ARRAY
		
		$input = array( 
			array('id'=>3, 'parent'=>2),
			array('id'=>1, 'parent'=>0),
			array('id'=>4, 'parent'=>0),
			array('id'=>2, 'parent'=>1),
		);
		$config = array(
			'addLevels' => true,
		);
		$result = sortToTree( $input, $config );
		$resultCorrect = array( 
			array('id'=>1, 'parent'=>0, 'level'=>0),
			array('id'=>2, 'parent'=>1, 'level'=>1),
			array('id'=>3, 'parent'=>2, 'level'=>2),
			array('id'=>4, 'parent'=>0, 'level'=>0),
		);

		$this->assertIdentical( $result, $resultCorrect );
		
		
		
		// TEST OBJECTS
		$a->id = 3;
		$a->parent = 2;
		$b->id= 1;
		$b->parent = 0;
		$c->id= 4;
		$c->parent = 0;	
		$d->id= 2;
		$d->parent = 1;
		$config = array(
			'addLevels' => true,
		);
		$result = sortToTree( $r = array(clone $a, clone $b, clone $c, clone $d), $config );
		
		$a->level = 2;
		$b->level = 0;
		$c->level = 0;
		$d->level = 1;
		$resultCorrect = array($b,$d,$a,$c);

		$this->assertIdentical( $result, $resultCorrect );
		
	}
}
?>